|
|
 |
|
|
|
|
cmdClose.Caption = "&Cancel"
Else
cmdClose.Caption = "&Close"
End If
cmdSave.Enabled = Not cmdSave.Enabled
cmdNew.Enabled = Not cmdNew.Enabled
cmdDelete.Enabled = Not cmdDelete.Enabled
lstNames.Enabled = Not lstNames.Enabled
End Sub |
|
|
|
|
|
|
|
|
You should also disable the list box so that the user cant click another employee while in the middle of editing or adding an employee record. |
|
|
|
|
|
|
|
|
To delete an employee record, the user needs to click the Delete command button. The Click event of the command button displays a message box asking the user to verify whether he or she really wants to delete this employees data. Heres the code: |
|
|
|
 |
|
|
|
|
Private Sub cmdDelete_Click()
Dim intResponse As Integer
Dim intIndex As Integer
Beep
intResponse = MsgBox("Delete the current Employee", _
vbYesNo + vbQuestion, _
"Delete Employee")
If intResponse = vbYes Then
intIndex = lstNames.ListIndex
moRS.Delete
lstNames.RemoveItem intIndex
intResponse = ListReposition(lstNames, intIndex)
If intResponse = -1 Then
Call Form_Activate
Else
lstNames.ListIndex = intResponse
End If
End If
End Sub |
|
|
|
|
|